// 公用方法2016-8-5
// 获取当前时间
var currentTime = function getNowFormatDate() {
	var date = new Date();
	var seperator1 = "-";
	var seperator2 = ":";
	var year = this.year = date.getFullYear()
	var month = this.month = date.getMonth() + 1;
	var strDate = this.strDate = date.getDate();
	var hour = this.hour = date.getHours();
	var mm = this.mm = date.getMinutes();
	if (month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if (strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	if (mm >= 0 && mm <= 9) {
		mm = "0" + mm;
	}
	this.currentDate = date.getFullYear() + seperator1 + month + seperator1 + strDate

	this.currentDatetime = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + mm;
	this.currentTime = date.getHours() + seperator2 + mm;
}
// 返回函数
function backClick() {
	api.closeWin();
}

function RefreshData() {
	$('#noNet').hide();
	showProgress();
	loadNewData();
}

function ObjectCount(o) {
	var t = typeof o;
	if (t == 'string') {
		return o.length;
	} else if (t == 'object') {
		var n = 0;
		for (var i in o) {
			n++;
		}
		return n;
	}
	return false;
}

//转换时间戳  2010-12-23 10:53
// 当前时间，年－月－日 时：分：秒
function getCurrentDate(ns) {

	var date = new Date(parseInt(ns) * 1000);

	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
	var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
	var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes());
	var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
	return Y + M + D + h + m;
}

function getCurrentDay(ns) {
	var date = new Date(parseInt(ns) * 1000);

	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
	return Y + M + D;
}

//时间转成时间戳
function timeStampWithString(timeString) {
	var tempStr = timeString.replace(/-/g, '/');
	var newTime = new Date(tempStr);
	return newTime.getTime() / 1000;
}

//图片预览
function showimg(imgages, i) {
	imgages = chagearr(imgages);
	var imageBrowser = api.require('imageBrowser');
	imageBrowser.openImages({
		imageUrls : imgages,
		showList : false,
		activeIndex : i,
	}, function(ret, err) {
		if (ret) {
			alert(JSON.stringify(ret));
		} else {
			alert(JSON.stringify(err));
		}
	});

}

//判断字符串为空
function isString(i) {
	var s = i;
	if (!isEmpty(s)) {
		return s;
	} else {
		return '暂无'
	}
}

//判断字符串为空
function isNullString(i) {
	var s = i;
	if (s != null && s != '' && s != 'null') {
		return true;
	} else {
		return false;
	}
}

//判断字符串为空
function isNullString2(i) {
	var s = i;
	if (s != null && s != '' && s != 'null' && s != undefined) {
		return s;
	} else {
		return '0';
	}
}

//根据数字反馈学生状态
function typeName(i) {

	switch(i) {
		case 0:
			return '未实习';
			break;
		case 1:
			return '实习中';
			break;
		case 2:
			return '实习结束';
			break;
		case 3:
			return '合格  ';
			break;
		case 4:
			return '良好';
			break;
		case 5:
			return '优秀';
			break;
		case 6:
			return '未结业';
			break;

		default:
	}

}

function chagearr(str) {

	if (str.constructor == Object) {
		//	alert("对象");

	} else if (str.constructor == Array) {
		//	alert("数组");
		return str;

	} else if (str.constructor == String) {
		//		alert("string"+str);
		return str.split(",");

	}
	;
}

//判断是否有前缀
function getpicurl(picurl) {
	var purl = "";

	if (picurl != '' && picurl != null) {

		if (picurl.indexOf("http") != -1) {//包含

			purl = picurl;
		} else {
			purl = $api.trimAll('http://cfnet.org.cn' + picurl);

		}
	} else {
		purl = "../../image/list-default.png";
	}
	return purl;

}

//判断头像是否为空
//判断头像是否为空
function HeadPortraitIsNull(picurl) {
	var purl = "";
	if (!isEmpty(picurl)) {
		if (picurl.indexOf("http") != -1) {//包含
			purl = picurl;
		} else {
			purl = $api.trimAll('http://cfnet.org.cn' + picurl);

		}
	} else {
		purl = "../../image/default_user_icon.png";
	}
	return purl;

}

//判断图片是否是百度云/阿里云上传图片
function PicDomainName(picurl, w) {
	var purl = "";
	var bosStr = '@s_0,w_' + w + '';
	var ossStr = '?x-oss-process=image/resize,w_' + w + ''

	if (picurl != '' && picurl != null) {
		if (w > 0) {
			if (picurl.indexOf("http") != -1) {//包含
				if (picurl.indexOf("bos") != -1) {
					purl = picurl + bosStr;
				} else if (picurl.indexOf("ossimg") != -1) {
					purl = picurl + ossStr;
				} else {
					purl = picurl;
				}
			} else {
				purl = "../../image/list-default.png";
			}
		} else {

			purl = picurl;
		}
	} else {
		purl = "../../image/list-default.png";
	}
	return purl;

}

function loadNewData() {
	page = 1;
	loadData();
}

function loadMoreData() {
	page++;
	loadData();
}

//时间戳转化为正常时间
function getLocalTime(x) {
	var now = new Date(parseInt(x) * 1000);
	var year = now.getFullYear();
	var month = Ten(now.getMonth() + 1);
	var date = Ten(now.getDate());

	return year + "-" + month + "-" + date;

}

////时间戳转化为正常时间
//function getLocalTimeTwo(now) {
//
//  var now = new Date(parseInt(x) );
//  var year = now.getFullYear();
//	var month = Ten(now.getMonth() + 1);
//	var date = Ten(now.getDate());
//
//	return year + "" + month + "" + date;
//
//}

//时间戳转化为正常时间
function getLocalSignTime(x) {
	var now = new Date(parseInt(x));
	var year = now.getFullYear();
	var month = Ten(now.getMonth() + 1);
	var date = Ten(now.getDate());

	return year + "" + month + "" + date;

}

function Ten(str) {
	var a = parseInt(str);
	if (a < 10) {
		return "0" + a;
	} else {
		return a;
	}

}

//显示加载框
function showProgress() {
	api.showProgress({
		style : 'default',
		animationType : 'fade',
		title : '加载中...',
		text : '',
		modal : true
	});
}

//隐藏加载框
function hideProgress() {
	api.hideProgress();
}

// 时间戳转化未时分秒
function getTimeHMS(timeStamp) {

	//时间戳转换
	var timeStampInt = parseInt(timeStamp);
	if (timeStamp.length == 10) {
		timeStampInt = timeStampInt * 1000;
	}
	var timeDate = new Date(timeStampInt);
	var timeYear = timeDate.getFullYear();
	var timeMonth = timeDate.getMonth() + 1;
	if (timeMonth < 10) {
		timeMonth = '0' + timeMonth;
	}
	var timeDay = timeDate.getDate();
	if (timeDay < 10) {
		timeDay = '0' + timeDay;
	}
	var timeHour = timeDate.getHours();
	if (timeHour < 10) {
		timeHour = '0' + timeHour;
	}
	var timeMinutes = timeDate.getMinutes();
	if (timeMinutes < 10) {
		timeMinutes = '0' + timeMinutes;
	}

	return timeYear + '-' + timeMonth + '-' + timeDay + ' ' + timeHour + ':' + timeMinutes;

}

//下拉刷新
function setRefreshHeader() {
	api.setRefreshHeaderInfo({
		visible : true,
		bgColor : '#ccc',
		textColor : '#fff',
		textDown : '下拉刷新...',
		textUp : '松开刷新...',
		showTime : true
	}, function(ret, err) {
		loadNewData();
	});
}

// 上拉加载
function setPullUpRefresh() {
	api.addEventListener({
		name : 'scrolltobottom'
	}, function(ret, err) {

		if (refreshCount >= row) {
			loadMoreData();
		}
	});
}

//弹出框
function ShowToast(b) {
	api.toast({
		msg : b,
		duration : 2000,
		location : 'bottom'
	});
}

//字符串非空判断
function isStringNull(b) {

	if (b == null || b == undefined || b == '') {

		return '';
	} else {
		return b;
	}

}

//字符超过十位，。。。。显示
function notTen(b) {
	var str = b;
	if (!isEmpty(str)) {
		if (str.length > 11) {
			b = str.substr(0, 10) + '.....';
			return b
		} else {
			return b
		}
	} else {
		return '无'
	}
}

//判断是否以http为前缀的图片地址
function httpImgUrl(img) {

	var str = img;

	if (str != undefined & str != null & str != '') {
		if (str.substr(0, 7) == "http://") {
			return str
		} else {

			return '../../image/list-default.png';
		}
	} else {
		return '../../image/list-default.png';
	}
}

//判断图片地址是否为空
function isNullImgUrl(img) {

	var str = img;

	if (!isEmpty(str)) {
		if (str.substr(0, 5) == "http:" || str.substr(0, 6) == "https:") {
			return str
		} else {

			return '../../image/course_placehoder.png';
		}
	} else {
		return '../../image/course_placehoder.png';
	}
}

//字符超过十位，。。。。显示
function notFive(b) {
	var str = b;

	if (str.length > 6) {
		b = str.substr(0, 5) + '.....';
		return b
	} else {
		return b
	}
}

////判断老师是否是管理员
//function judgeAdministrator() {
//	cfnetppPOST(urlClasslist, {
//		uid : $api.getStorage('cfnetppuid'),
//		jid : $api.getStorage('cfnetppjid')
//	}, true, function(data, status) {
//		if (status == 'success') {//获取网络
//			if (data.status == 1) {
//				var list = data.json;
//				if (list.constructor == Array && list.length > 0) {
//				} else {
//					api.toast({
//						msg : '您当前尚未管理班级，无对应数据',
//						duration : 2000,
//						location : 'bottom'
//					});
//				}
//			} else {
//				api.toast({
//					msg : '您当前尚未管理班级，无对应数据',
//					duration : 2000,
//					location : 'bottom'
//				});
//			}
//		} else {
//			api.toast({
//				msg : '获取失败!请检查网络',
//				duration : 2000,
//				location : 'bottom'
//			});
//		}
//	});
//}

//截取绝对路径下的文件名
function splitFileName(path) {
	var locHref = path;
	var locArray = locHref.split("/");
	var newPath = locArray[locArray.length - 1];
	return newPath;
	//输出结果 p8.jpg

}

//获取文件类型
function plitFileType(url) {
	var path = splitFileName(url);
	//文件后缀名
	var ext = path.replace(/.+\./, "");
	//小写格式
	var extLower = ext.toLowerCase();
	return extLower;
}

//b转换成kb
function bytesToSize(bytes) {
	if (bytes === 0)
		return '0 B';

	var k = 1024;

	sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

	i = Math.floor(Math.log(bytes) / Math.log(k));

	return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
	//toPrecision(3) 后面保留一位小数，如1.0GB                                                                                                                  //return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
}

//去标签方法
function htmlspecialchars_decode(str) {

	if (str != null && str != "") {
		if (str.constructor == String) {
			str = str.replace(/<\/?.+?>/g, "");
			str = str.replace(/&amp;/g, '&');
			str = str.replace(/&lt;/g, '<');
			str = str.replace(/&gt;/g, '>');
			str = str.replace(/&quot;/g, "''");
			str = str.replace(/&#039;/g, "'");
			str = str.replace(/&nbsp;/ig, '');

			return str;
		} else {
			return str;
		}

	}

}

//去标签方法
function htmlspecialchars_decode_question(str) {

	if (str != null && str != "") {
		if (str.constructor == String) {
			//			str = str.replace(/<\/?.+?>/g, "");
			str = str.replace(/<p>(.*?)<\/p>/g, "$1")
			str = str.replace(/<img.*?(?:>|\/>)/gi, "");
			str = str.replace(/<video>(.*?)<\/video>/g, "");
			str = str.replace(/\<p class=\"edui-video-resource\".*?>.*?<\/p>/g, "");
			str = str.replace(/width:\s\d*px;/g, "width: auto;");
			str = str.replace(/width:\d*;/g, "width:auto;");
			str = str.replace(/_width=\"\d*\"/g, "");
			str = str.replace(/&amp;/g, '&');
			str = str.replace(/&lt;/g, '<');
			str = str.replace(/&gt;/g, '>');
			str = str.replace(/&quot;/g, "''");
			str = str.replace(/&#039;/g, "'");
			str = str.replace(/&nbsp;/ig, '');
			return str;
		} else {
			return str;
		}

	}

}

//utf-8转gb2312
function gb2utf8(data) {
	var glbEncode = [];
	gb2utf8_data = data;
	execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
	var t = escape(gb2utf8_data).replace(/%u/g, "").replace(/(.{2})(.{2})/g, "%$2%$1").replace(/%([A-Z].)%(.{2})/g, "@$1$2");
	t = t.split("@");
	var i = 0, j = t.length, k;
	while (++i < j) {
		k = t[i].substring(0, 4);
		if (!glbEncode[k]) {
			gb2utf8_char = eval("0x" + k);
			execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
			glbEncode[k] = escape(gb2utf8_char).substring(1, 6);
		}
		t[i] = glbEncode[k] + t[i].substring(4);
	}
	gb2utf8_data = gb2utf8_char = null;
	return unescape(t.join("%"));
}

//gb2312转utf-8
function GB2312UTF8() {
	this.Dig2Dec = function(s) {
		var retV = 0;
		if (s.length == 4) {
			for (var i = 0; i < 4; i++) {
				retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
			}
			return retV;
		}
		return -1;
	}
	this.Hex2Utf8 = function(s) {
		var retS = "";
		var tempS = "";
		var ss = "";
		if (s.length == 16) {
			tempS = "1110" + s.substring(0, 4);
			tempS += "10" + s.substring(4, 10);
			tempS += "10" + s.substring(10, 16);
			var sss = "0123456789ABCDEF";
			for (var i = 0; i < 3; i++) {
				retS += "%";
				ss = tempS.substring(i * 8, (eval(i) + 1) * 8);
				retS += sss.charAt(this.Dig2Dec(ss.substring(0, 4)));
				retS += sss.charAt(this.Dig2Dec(ss.substring(4, 8)));
			}
			return retS;
		}
		return "";
	}
	this.Dec2Dig = function(n1) {
		var s = "";
		var n2 = 0;
		for (var i = 0; i < 4; i++) {
			n2 = Math.pow(2, 3 - i);
			if (n1 >= n2) {
				s += '1';
				n1 = n1 - n2;
			} else
				s += '0';
		}
		return s;
	}

	this.Str2Hex = function(s) {
		var c = "";
		var n;
		var ss = "0123456789ABCDEF";
		var digS = "";
		for (var i = 0; i < s.length; i++) {
			c = s.charAt(i);
			n = ss.indexOf(c);
			digS += this.Dec2Dig(eval(n));
		}
		return digS;
	}
	this.Gb2312ToUtf8 = function(s1) {
		var s = escape(s1);
		var sa = s.split("%");
		var retV = "";
		if (sa[0] != "") {
			retV = sa[0];
		}
		for (var i = 1; i < sa.length; i++) {
			if (sa[i].substring(0, 1) == "u") {
				retV += this.Hex2Utf8(this.Str2Hex(sa[i].substring(1, 5)));
				if (sa[i].length) {
					retV += sa[i].substring(5);
				}
			} else {
				retV += unescape("%" + sa[i]);
				if (sa[i].length) {
					retV += sa[i].substring(5);
				}
			}
		}
		return retV;
	}
	this.Utf8ToGb2312 = function(str1) {
		var substr = "";
		var a = "";
		var b = "";
		var c = "";
		var i = -1;
		i = str1.indexOf("%");
		if (i == -1) {
			return str1;
		}
		while (i != -1) {
			if (i < 3) {
				substr = substr + str1.substr(0, i - 1);
				str1 = str1.substr(i + 1, str1.length - i);
				a = str1.substr(0, 2);
				str1 = str1.substr(2, str1.length - 2);
				if (parseInt("0x" + a) & 0x80 == 0) {
					substr = substr + String.fromCharCode(parseInt("0x" + a));
				} else if (parseInt("0x" + a) & 0xE0 == 0xC0) {//two byte
					b = str1.substr(1, 2);
					str1 = str1.substr(3, str1.length - 3);
					var widechar = (parseInt("0x" + a) & 0x1F) << 6;
					widechar = widechar | (parseInt("0x" + b) & 0x3F);
					substr = substr + String.fromCharCode(widechar);
				} else {
					b = str1.substr(1, 2);
					str1 = str1.substr(3, str1.length - 3);
					c = str1.substr(1, 2);
					str1 = str1.substr(3, str1.length - 3);
					var widechar = (parseInt("0x" + a) & 0x0F) << 12;
					widechar = widechar | ((parseInt("0x" + b) & 0x3F) << 6);
					widechar = widechar | (parseInt("0x" + c) & 0x3F);
					substr = substr + String.fromCharCode(widechar);
				}
			} else {
				substr = substr + str1.substring(0, i);
				str1 = str1.substring(i);
			}
			i = str1.indexOf("%");
		}

		return substr + str1;
	}
}

function sZhuanHms(time) {//秒转时分秒
	var timeStr = '';
	var hour = parseInt(time / 3600);
	if (hour >= 1) {
		if (hour < 10) {
			hour = '0' + hour;
		}
		timeStr += hour + ':';
	}
	time = time % 3600;
	var min = parseInt(time / 60);
	if (min >= 1) {
		if (min < 10) {
			min = '0' + min;
		}
		timeStr += min + ':';
	} else {
		timeStr += '00:';
	}
	time = time % 60;
	if (time < 10) {
		time = '0' + time;
	}
	timeStr += time;
	return timeStr;
}

//1分钟以内显示为：刚刚
//1小时以内显示为：N分钟前
//当天以内显示为：今天 N点N分（如：今天 22:33）
//昨天时间显示为：昨天 N点N分（如：昨天 10:15）
//当年以内显示为：N月N日 N点N分（如：02月03日 09:33）
//今年以前显示为：N年N月N日 N点N分（如：2000年09月18日 15:59）
function timestampFormat(timestamp) {
	function zeroize(num) {
		return (String(num).length == 1 ? '0' : '') + num;
	}

	var curTimestamp = parseInt(new Date().getTime() / 1000);
	//当前时间戳
	var timestampDiff = curTimestamp - timestamp;
	// 参数时间戳与当前时间戳相差秒数

	var curDate = new Date(curTimestamp * 1000);
	// 当前时间日期对象
	var tmDate = new Date(timestamp * 1000);
	// 参数时间戳转换成的日期对象

	var Y = tmDate.getFullYear(), m = tmDate.getMonth() + 1, d = tmDate.getDate();
	var H = tmDate.getHours(), i = tmDate.getMinutes(), s = tmDate.getSeconds();

	if (timestampDiff < 60) {// 一分钟以内
		return "刚刚" + ' ' + "回复";
	} else if (timestampDiff < 3600) {// 一小时前之内
		return Math.floor(timestampDiff / 60) + "分钟前" + ' ' + "回复";
	} else if (curDate.getFullYear() == Y && curDate.getMonth() + 1 == m && curDate.getDate() == d) {
		return '今天' + zeroize(H) + ':' + zeroize(i) + ' ' + "回复";
	} else {
		var newDate = new Date((curTimestamp - 86400) * 1000);
		// 参数中的时间戳加一天转换成的日期对象
		if (newDate.getFullYear() == Y && newDate.getMonth() + 1 == m && newDate.getDate() == d) {
			return '昨天' + zeroize(H) + ':' + zeroize(i) + ' ' + "回复";
		} else if (curDate.getFullYear() == Y) {
			return zeroize(m) + '月' + zeroize(d) + '日 ' + zeroize(H) + ':' + zeroize(i) + ' ' + "回复";
		} else {
			return Y + '年' + zeroize(m) + '月' + zeroize(d) + '日 ' + zeroize(H) + ':' + zeroize(i) + ' ' + "回复";
		}
	}
}

//数字转字母
function fromCharCode(num) {
	if (num != null && num != '') {
		var a = String.fromCharCode(64 + (parseInt(num)))

		return a;
	} else {
		return '';

	}
}

//字母转数字
function charCodeAt(num) {
	if (num != null && num != '') {
		var a = num.charCodeAt(0) - 64;

		return a;
	} else {
		return '';
	}
}

function learnImgUrl(img) {

	var str = img;
	if (str != undefined & str != null & str != '') {
		if (str.substr(0, 7) == "http://") {
			return str
		} else {

			return 'http://cfnet.org.cn/data/uploads/' + str;
		}
	} else {
		return '../../image/list-default.png';
	}
}

function headImgUrl(img) {
	var str = img;
	if (!isEmpty(str)) {
		if (str.substr(0, 7) == "http://") {
			return str
		} else {

			return 'http://cfnet.org.cn/data/uploads/' + str;
		}
	} else {
		return '../../image/default_user_icon.png';
	}
}

function skillImgUrl(img) {

	var str = img;
	if (str != undefined & str != null & str != '') {
		if (str.substr(0, 7) == "http://") {
			return str
		} else {
			return 'http://cfnet.org.cn/public/book/upload/' + str;
		}
	} else {
		return '../../image/list-default.png';
	}
}

//通过id得到名称
function ByIdGetQuestionTypeName(id) {
	var num = parseInt(id);
	var typeName = '';
	switch(num) {
		case 1:
			typeName = '单选题';
			break;
		case 2:
			typeName = '多选题';
			break;
		case 3:
			typeName = '判断题';
			break;
		case 4:
			typeName = '论述题';
			break;
		case 5:
			typeName = '上传题';
			break;
		case 7:
			typeName = '识图题';
			break;
		case 8:
			typeName = '流程排序题';
			break;
		case 9:
			typeName = '视频题';
			break;
		case 10:
			typeName = '案例分析题';
			break;
		case 11:
			typeName = '填空题';
			break;
		default:
	}
	return typeName;
}

//获取文本中html代码
function removeHTMLTag(str) {
	str = str.replace(/<\/?[^>]*>/g, '');
	//去除HTML tag
	str = str.replace(/[ | ]*\n/g, '\n');
	//去除行尾空白
	//str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
	str = str.replace(/&nbsp;/ig, '');
	//去掉&nbsp;
	str = str.replace(/\s/g, '');
	//将空格去掉
	return str;
}

function getImgSrc(introduce) {
	var totalStr = introduce
	var re = /<p[^>]+>/g;
	var a = totalStr.match(re);

	return a
}

//数字为空为null
function numNull(a) {
	var num = a;
	if (num == null || num == "" || num == 0) {
		return 0
	} else {
		return a
	}
}

//产生随机数

function getRandom(n) {
	return Math.floor(Math.random() * n + 1)
}

//替换图片样式
function replace_width(str) {
	//全局替换/img/g格式
	var type = str.indexOf("http");
	if (type > 0) {
		var width = api.winWidth - 20;
		str = str.replace(/max-width:600px;height:auto/g, "width:" + width + "px");
		str = str.replace(/max-width: 600px; height: 398px; width: 533px/g, "width:" + width + "px");
		str = str.replace(/text-align: center;/g, "width:" + width + "px");
		str = str.replace(/width="300px"/g, "width:" + width + "px");
	}

	return str;
}

//替换图片名前缀加上
function replace_imgHttp(str) {
	var type = str.indexOf("/uploads");
	if (type > 0) {

		str = str.replace(/uploads/g, "cfnet.org.cn/uploads");

	}
	return str;
}

//为了解决content错版的方法
//去掉html标签
function removeHtmlTab(tab) {
	return tab.replace(/<[^<>]+?>/g, '');
	//删除所有HTML标签
}

//普通字符转换成转意符
function html2Escape(sHtml) {
	return sHtml.replace(/[<>&"]/g, function(c) {
		return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];
	});
}

//转意符换成普通字符
function escape2Html(str) {
	var arrEntities = {
		'lt' : '<',
		'gt' : '>',
		'nbsp' : ' ',
		'amp' : '&',
		'quot' : '"'
	};
	return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function(all, t) {
		return arrEntities[t];
	});
}

// &nbsp;转成空格
function nbsp2Space(str) {
	var arrEntities = {
		'nbsp' : ' '
	};
	return str.replace(/&(nbsp);/ig, function(all, t) {
		return arrEntities[t]
	})
}

//回车转为br标签
function return2Br(str) {
	return str.replace(/\r?\n/g, "<br />");
}

//去除开头结尾换行,并将连续3次以上换行转换成2次换行
function trimBr(str) {
	str = str.replace(/((\s|&nbsp;)*\r?\n){3,}/g, "\r\n\r\n");
	//限制最多2次换行
	str = str.replace(/^((\s|&nbsp;)*\r?\n)+/g, '');
	//清除开头换行
	str = str.replace(/((\s|&nbsp;)*\r?\n)+$/g, '');
	//清除结尾换行
	return str;
}

// 将多个连续空格合并成一个空格
function mergeSpace(str) {
	str = str.replace(/(\s|&nbsp;)+/g, ' ');
	return str;
}

//我的认证列表展示提示语
function showPrompt(type) {
	var num = parseInt(type);
	switch(num) {
		case 2:
			ShowToast('恭喜您预约成功');
			break;
		case 4:
			ShowToast('正在阅卷中，请耐心等待');
			break;
		case 5:
			ShowToast('恭喜您认证成功');
			break;
		default:
	}
}

//UI滑动
function scrollUI() {
	mui.ready(function() {
		mui('.mui-scroll-wrapper').scroll();
	});
}

/*传入的是带有img标签的html的json字符串,实现了点击图片放大查看*/
function imageTapToSee(newsDetailsContent) {

	$('#newsDetailsContent img').on('click', function() {

		showimg([$(this).attr("src")], 0);

	});

}

function backIndex() {
	api.closeToWin({
		name : 'index'
	});
}

//将数组转化成字符串
function arrToString(arr) {
	return arr.join(",");

}

//将字符串转化为数组
function stringToArr(string) {
	return string.split(",");

}

//输入是否包含指定元素
function arrContainEle(arr, ele) {
	for (var i = 0; i < arr.length; i++) {
		if (arr[i] == ele)
			return true;
	}
	return false;
}

//textarea自增长
function ResizeTextarea(id) {
	var index = 'textarea' + id;
	if (id != null && id != '') {
		var minHeight = 100;
		// 最大高度，超过则出现滚动条
		var maxHeight = 300;
		var t = document.getElementById(index);
		h = t.scrollHeight;
		h = h > minHeight ? h : minHeight;
		h = h > maxHeight ? maxHeight : h;
		t.style.height = h + "px";
	}
}

//获取html代码中的试题,并拼接成数组
function GetHtmlTestList(list) {
	var data = list;
	var dataArr = new Array();
	var danArr = new Array();
	var duoArr = new Array();
	var panArr = new Array();
	var shituArr = new Array();
	var paixuArr = new Array();
	var shipinArr = new Array();
	var lunshuArr = new Array();
	var anliArr = new Array();
	if (data != null && data != '') {
		if (data.dan != undefined && data.dan.length > 0 && data.dan != '' && data.dan != null) {
			for (var i = 0; i < data.dan.length; i++) {
				var weeklyData = data.dan[i];
				danArr.push(weeklyData);
			}
		}
		if (data.duo != undefined && data.duo.length > 0 && data.duo != '' && data.duo != null) {
			for (var i = 0; i < data.duo.length; i++) {
				var duoData = data.duo[i];
				duoArr.push(duoData);
			}
		}
		if (data.pan != undefined && data.pan.length > 0 && data.pan != '' && data.pan != null) {
			for (var i = 0; i < data.pan.length; i++) {
				var panData = data.pan[i];
				panArr.push(panData);
			}
		}
		if (data.lunshu != undefined && data.lunshu.length > 0 && data.lunshu != '' && data.lunshu != null) {
			for (var i = 0; i < data.lunshu.length; i++) {
				var lunshuData = data.lunshu[i];
				lunshuArr.push(lunshuData);
			}
		}
		if (data.shitu != undefined && data.shitu.length > 0 && data.shitu != '' && data.shitu != null) {
			for (var i = 0; i < data.shitu.length; i++) {
				var shituData = data.shitu[i];
				shituArr.push(shituData);
			}
		}
		if (data.paixu != undefined && data.paixu.length > 0 && data.paixu != '' && data.paixu != null) {
			for (var i = 0; i < data.paixu.length; i++) {
				var paixuData = data.paixu[i];
				paixuArr.push(paixuData);
			}
		}
		if (data.shipin != undefined && data.shipin.length > 0 && data.shipin != '' && data.shipin != null) {
			for (var i = 0; i < data.shipin.length; i++) {
				var shipinData = data.shipin[i];
				shipinArr.push(shipinData);
			}
		}
		if (data.anli != undefined && data.anli.length > 0 && data.anli != '' && data.anli != null) {
			for (var i = 0; i < data.anli.length; i++) {
				var anliData = data.anli[i];
				anliArr.push(anliData);
			}
		}
		dataArr = dataArr.concat(danArr, duoArr, panArr, lunshuArr, shituArr, paixuArr, shipinArr, anliArr);
		SetUI(dataArr);
	}
}

//获取html代码中的试题,并拼接成数组
function GetHtmlTestArrayList(list) {
	var data = list;
	var dataArr = new Array();
	var danArr = new Array();
	var duoArr = new Array();
	var panArr = new Array();
	var shituArr = new Array();
	var paixuArr = new Array();
	var shipinArr = new Array();
	var lunshuArr = new Array();
	var anliArr = new Array();
	var chuanArr = new Array();
	if (data != null && data != '') {
		if (data.dan != undefined && data.dan.length > 0 && data.dan != '' && data.dan != null) {
			for (var i = 0; i < data.dan.length; i++) {
				var weeklyData = data.dan[i];
				danArr.push(weeklyData);
			}
		}

		if (data.duo != undefined && data.duo.length > 0 && data.duo != '' && data.duo != null) {
			for (var i = 0; i < data.duo.length; i++) {
				var duoData = data.duo[i];
				duoArr.push(duoData);
			}
		}
		if (data.pan != undefined && data.pan.length > 0 && data.pan != '' && data.pan != null) {
			for (var i = 0; i < data.pan.length; i++) {
				var panData = data.pan[i];
				panArr.push(panData);
			}
		}
		if (data.lunshu != undefined && data.lunshu.length > 0 && data.lunshu != '' && data.lunshu != null) {
			for (var i = 0; i < data.lunshu.length; i++) {
				var lunshuData = data.lunshu[i];
				lunshuArr.push(lunshuData);
			}
		}
		if (data.shitu != undefined && data.shitu.length > 0 && data.shitu != '' && data.shitu != null) {
			for (var i = 0; i < data.shitu.length; i++) {
				var shituData = data.shitu[i];
				shituArr.push(shituData);
			}
		}
		if (data.paixu != undefined && data.paixu.length > 0 && data.paixu != '' && data.paixu != null) {
			for (var i = 0; i < data.paixu.length; i++) {
				var paixuData = data.paixu[i];
				paixuArr.push(paixuData);
			}
		}
		if (data.shipin != undefined && data.shipin.length > 0 && data.shipin != '' && data.shipin != null) {
			for (var i = 0; i < data.shipin.length; i++) {
				var shipinData = data.shipin[i];
				shipinArr.push(shipinData);
			}
		}
		if (data.anli != undefined && data.anli.length > 0 && data.anli != '' && data.anli != null) {
			for (var i = 0; i < data.anli.length; i++) {
				var anliData = data.anli[i];
				anliArr.push(anliData);
			}
		}
		if (data.chuan != undefined && data.chuan.length > 0 && data.chuan != '' && data.chuan != null) {
			for (var i = 0; i < data.chuan.length; i++) {
				var chuanData = data.chuan[i];
				chuanArr.push(chuanData);
			}
		}

		dataArr = dataArr.concat(danArr, duoArr, panArr, lunshuArr, shituArr, paixuArr, shipinArr, anliArr, chuanArr);
		return dataArr;
	}
}

/*ios系统的状态栏*/
function DetermineTheIosStatusBarar() {
	var systemType = api.systemType;
	if (systemType == 'ios') {
		api.setStatusBarStyle({
			style : 'light'
		});
	}
}

//新闻详情表格过大
function replace_newsDetails(str) {

	var type = str.indexOf("cellpadding=");
	if (type > 0) {
		var width = api.winWidth - 20;
		str = str.replace(/cellpadding=\"0\" width=\"549\"/g, 'cellpadding=\"0\" width=' + width + 'px');
		//width=\"306\
		str = str.replace(/<td width=\"306\"/g, '<td width=\"516\"');
		//text-indent
		str = str.replace(/text-indent:28px/g, 'text-indent:5px');
		// width=\"568\"
		str = str.replace(/width=\"568\"/g, "width=" + width + "px");
		//font-family:华文细黑
		str = str.replace(/font-family:华文细黑/g, 'font-family:微软雅黑');

	}

	return str;
}

function scoreAlertYes() {
	$('#scoreAlert').hide();
	backClick();

}

//退出考试提示
function back(str) {

	$("#checkNum2").text(str);
	$('#closeAlert').show();
}

function Cancel() {
	if (clickNum == 4) {
		$('#closeAlert').hide();
	} else {
		$('#closeAlert').hide();
		backClick();
	}
}

//  试题总数
function allQuestionNum(questionLen) {
	$("#questionLength").text("/" + questionLen)
}

//设置沉浸式
function setBarAppearance() {

	$("#BarAppearance").css('height', getBarAppearanceHeight());

}

//获取沉浸式的高度
function getBarAppearanceHeight() {
	var systemType = api.systemType + '';
	var Height = '';
	if (systemType == 'ios') {
		Height = 20;
	} else {
		Height = 25;
	}
	return Height;
}

//图片未找到时，默认显示图片
function Imgnofind() {
	var img = event.srcElement;
	img.src = "../../image/course_placehoder.png";
	img.onerror = null;
}

//主观题？客观题
function strReturnResearchType(str) {
	if (str != null && str != '') {
		if (str == '单选题' || str == '多选题') {
			return 1;
		} else if ( str = '开放题') {
			return 0;
		}
	}
}

//单选题or多选题or开放题
function str2ReturnResearchType(str) {
	if (str != null && str != '') {
		if (str == '单选题') {
			return 1;
		} else if (str == '多选题') {
			return 2;
		} else if ( str = '开放题') {
			return 3;
		}
	}
}

//判断一组文本框中是否有重复值
function sameNameText(ob) {
	var reRecords = new Array();
	var len = ob.length;
	for (var i = 0; i <= ob.length; i++) {
		if (ob[i] != null) {
			var v1 = ob[i].desc;
		}
		//alert(v1);
		for (var j = i + 1; j <= ob.length; j++) {
			if (ob[j] != null) {
				var v2 = ob[j].desc;

				if (v1 == v2) {
					reRecords[reRecords.length] = v2;
					//break;
				}
			}
		}
	}
	//		alert(JSON.stringify(reRecords));
	return reRecords;
}

//数组去重，返回数组长度
function unique(arr) {
	var res = new Array();
	var json = {};
	for (var i = 0; i < arr.length; i++) {
		if (!json[arr[i]]) {
			res.push(arr[i]);
			json[arr[i]] = 1;
		}
	}
	return res.length;
}

//判断一组文本框中是否有空值
function ArrNullText(ob) {
	var reRecords = new Array();
	var reg = /\s/;

	var len = ob.length;
	for (var i = 0; i <= ob.length; i++) {
		if (ob[i] != null && ob[i] != '' && ob[i] != undefined && ob[i] != '{}') {
			var v1 = ob[i].desc.trim();
			if (v1 == "" || v1 == undefined || isOnlySpaceOrEnter(v1)) {
				reRecords.push(i);

			} else {
				//				reRecords[i] = ''
			}
		} else {
			//			reRecords.push(i);
		}

	}
	return reRecords;
}

function ReturnSelectNum(ob) {

	var reRecords = new Array();
	var reg = /\s/;
	var len = ob.length;
	for (var i = 0; i <= ob.length; i++) {
		if (ob[i] != null && ob[i] != '' && ob[i] != undefined && ob[i] != '{}') {
			var v1 = ob[i].state;
			var v2 = ob[i].check_all;
			if (v1 == true || v2 == true) {
				reRecords.push(i);

			} else {
				//				reRecords[i] = ''
			}
		} else {
			//			reRecords.push(i);
		}

	}
	return reRecords.length;
}

//返回空选项个数
function isTrueSelectNum(ob) {
	var reRecords = new Array();
	var reg = /\s/;
	var len = ob.length;
	for (var i = 0; i <= ob.length; i++) {
		if (ob[i] != null && ob[i] != '' && ob[i] != undefined && ob[i] != '{}') {
			var v1 = ob[i].state;
			var v2 = ob[i].check_all;

			if (v1 == true && (v2 == false || ob[i].hasOwnProperty("check_all") == false)) {
				reRecords.push(i);

			} else {
				//				reRecords[i] = ''
			}
		} else {
			//			reRecords.push(i);
		}

	}
	return reRecords.length;
}

//返回空选项个数
function isTrueCheckNum(ob) {
	var reRecords = new Array();
	var reg = /\s/;
	var len = ob.length;
	for (var i = 0; i <= ob.length; i++) {
		if (ob[i] != null && ob[i] != '' && ob[i] != undefined && ob[i] != '{}') {
			var v1 = ob[i].check_all;
			//			var v2 = ob[i].state;
			if (v1 == false && ob[i].hasOwnProperty("check_all")) {
				reRecords.push(i);

			} else {
				//				reRecords[i] = ''
			}
		} else {
			//			reRecords.push(i);
		}

	}
	return reRecords.length;
}

//考试题目数组不能为空
function ArrayIsNull(arr) {
	var allStudentClass = {
		xuanzhe : '无选项',
		daan : '0'
	};
	var arr2 = new Array();
	if (JSON.stringify(arr) === '[]' || arr == null) {
		arr2[0] = allStudentClass;
		return arr2;
	} else {
		return arr;
	}

}

//function qxuanxiangIsNull(arr) {
//alert(arr)
//  var arr2= JSON.stringify(arr);
//	var sclass = {
//		xuanzhe : '无选项',
//		daan : '0'
//	};
////	var arr2 = new Array();
//	if (arr == null || arr== ''||arr == "null" ) {
//      alert('sss');
//		return '';
//	} else {
//
//		return JSON.parse(arr);
//	}
//
//}

function qxuanxiangIsNull(arr) {

	var qxuan = '';
	if (arr != "null" && arr != '' && arr != null) {
		if ( typeof arr == 'string') {
			qxuan = JSON.parse(arr)
		} else {
			qxuan = arr
		}
		return qxuan
	} else {

		qxuan = [{
			xuanzhe : '无选项',
			daan : '0'
		}];
		return qxuan

	}

}

//提交结果不能为空
function dtjieguoIsNull(str) {
	if (str == null || str == '') {
		return '无提交结果'
	} else {
		return str
	}
}

//禁止空字符串进行spite操作
function strIsNullSpite(str) {
	if (str == '' || str == null) {
		return ''
	} else {
		if (str.indexOf("|") != -1) {
			return str.split("|").sort();
		} else {
			return str;
		}
	}

}

//如果是数字,使用spite排序,使用sort排序
function numIsNullSpite(str) {
	if (str == '' || str == null) {
		return ''
	} else {
		return str.split("|").sort();
	}

}

//判断字符串中是否只有空格或回车--如果为空传则返回true，如果不是空传则返回false
function isOnlySpaceOrEnter(str) {
	str = str.replace(/\s+/g, "");
	str = str.replace(/[\r\n]/g, "");
	if (str == '') {
		return true;
	} else {
		return false;
	}
}

//是否是大写字母
function isUpperCase(ch) {
	if (!isEmpty(ch)) {
		if (/[A-Z]/.test(ch)) {//大写字母
			return charCodeAt(ch)

		} else {
			return ch;
		}

	} else {

		return ''
	}
}

//提取cjjieguo字段的键值
function getCjjieguoKey(obj) {
	var keys1 = [];
	if (obj != '' && obj != null && obj != undefined) {

		if ( typeof obj == 'object') {
			for (var p1 in obj) {
				if (obj.hasOwnProperty(p1)) {
					keys1.push(isUpperCase(p1));
				}
			}
			return keys1.sort();
		} else if ( typeof obj == 'string') {
			return strIsNullSpite(obj);

		} else {
			return '';
		}
	} else {
		return '';
	}
}

//判断字符串中是否含有竖线
function isVerticalLine() {

}

//提交按钮监听
function SubBtnlisten() {
	var winHeight = $(window).height();
	//获取当前页面高度
	$(window).resize(function() {
		var thisHeight = $(this).height();
		if (winHeight - thisHeight > 50) {
			//当软键盘弹出，在这里面操作
			$("#sub_div").css('display', 'none');
		} else {
			$("#sub_div").css('display', 'block');
			//当软键盘收起，在此处操作
		}
	});
}

//调查章节柱状图
function GetWidth() {
	var lines = $(".Bar_center");
	for (var i = 0; i < lines.length; i++) {

		//		var numP = parseInt(lines.eq(i).text().replace(/[^0-9]+/g, ''));
		var numP = Math.round(lines.eq(i).text().replace('%', ''));
		var ww = $(".Bar_left").width() * (numP / 100);
		lines.eq(i).prev().children('.bar_in').css('width', ww);
	}
}

//判断是否为英文字母
function check_letter(obj) {
	if (obj != '' && obj != null && obj != undefined) {
		if (/^[A-Za-z]+$/.test(obj)) {
			return charCodeAt(obj);
		} else if (isNaN(obj)) {
			return obj;
		} else {
			return '';
		}
	} else {
		return '';
	}
}

//百分比默认显示0
function PercentageIsNull(str) {
	//	alert(str)
	if (str == '' || str == null || isNaN(parseInt(str)) || str == undefined || parseInt(str) > 100 || parseInt(str) < 0) {

		return 0;

	} else {
		if (isInteger(str) == true) {

			return str;

		} else {
			return str.toFixed(1);
		}
	}

}

//判断当前数字是否为整数
function isInteger(obj) {
	return Math.floor(obj) === obj
}

//多个图片本地缓存
function multiplePicturesCache(param, callBack) {
	var picArr = param.picArr;
	//存图片的对象数组
	var picKey = param.picKey;
	//图片对应键
	var isOriginals = param.isOriginals;
	//是否源文件
	var thumbnail = true;
	if (isOriginals == 1) {
		thumbnail = false;
	}
	var newArr = new Array();
	if (picKey == undefined || picKey == null || picKey == '') {
		callBack(newArr);
		return;
	}
	if (picArr != undefined && picArr != null && picArr.constructor == Array && picArr.length > 0) {
		var j = 0;
		var count = picArr.length
		for (var i = 0; i < count; i++) {
			var picData = picArr[i];
			var currentPath = picData[picKey];
			if (currentPath == undefined || currentPath == null || currentPath == '') {
				j++;
				if (j == count) {//所有图片替换完毕
					// callBack(newArr);
					callBack(picArr);
				}
				continue;
			}
			picData[picKey] = imageUrlWithStr(currentPath);
			j++;
			if (j == count) {//所有图片替换完毕
				// callBack(newArr);
				callBack(picArr);
			}
			// localImageDataWithImageData(picData, picKey, thumbnail, function(newPicData) {
			// 	// newArr.push(newPicData);
			// 	j++;
			// 	if (j == count) {//所有图片替换完毕
			// 		// callBack(newArr);
			// 		callBack(picArr);
			// 	}
			// });
		}
	} else {
		callBack(newArr);
	}
}

function imageUrlWithStr(string) {
	if (string == null || string == undefined || string == '') {
		return '';
	}
	if (string.indexOf("http://") == -1) {
		if (string.indexOf("learn/") == -1) {
			return 'http://bos.cfnet.org.cn/' + string;
		} else {
			return 'http://cfnet.org.cn/data/uploads/' + string;
		}
	} else {
		return string;
	}
}

function strIsNum(str) {
	var val = str

	if (val != null && val != undefined && val != '' && val != Infinity) {
		if (!isNaN(val)) {
			return val.toFixed(2);
		} else {
			return 0;
		}
	} else {
		return 0;
	}
}

function localImageDataWithImageData(imageData, picKey, thumbnail, callBack) {
	api.imageCache({
		url : imageData[picKey],
		thumbnail : thumbnail
	}, function(ret, err) {
		imageData[picKey] = ret.url;
		callBack(imageData);
	});
}

//是否免登陆
function isfreelogin(islogis, url) {
	if (islogis == 1) {//1免登陆 0不免登陆
		//$api.getStorage('cfnetppjxid')由于实习时集团下要修改，故要用tempjid替换index页下的jxid
		var jid = $api.getStorage('tempjid');
		if (jid == '' || jid == null) {
			jid = '419';
		}
		var unameStr = $api.getStorage('cfnetppusername');
		if (unameStr == '' || unameStr == null) {
			unameStr = '匿名';
		}
		var uid = $api.getStorage('cfnetppuid');
		var strmd5 = MD5(jid + uid + unameStr + "cfnetapp");

		return url + "?jid=" + jid + "&uid=" + uid + "&uname=" + unameStr + "&sources=3&stoken=" + strmd5;
	} else {
		return url;
	}
}

//公共打印方法
function popu(str) {

//	alert(JSON.stringify(str))

}

//获取html代码中的试题,并拼接成数组
function GetQuanList(list) {
	var quanArr = new Array();
	if (list.hasOwnProperty("R")) {
		quanArr = list.R;
	} else if (list.hasOwnProperty("A")) {
		quanArr = list.A;
	} else if (list.hasOwnProperty("S")) {
		quanArr = list.S;
	} else if (list.hasOwnProperty("E")) {
		quanArr = list.E;
	} else if (list.hasOwnProperty("C")) {
		quanArr = list.C;
	} else if (list.hasOwnProperty("I")) {
		quanArr = list.I;
	}
	return quanArr;
}

function isSameToday(str, str2) {
	if (new Date(str).toDateString() === new Date(str2).toDateString()) {
		return true;
	} else if (new Date(str) < new Date(str2)) {
		return false;
	}
}

//判断当前提交时间和补交时间是否在同一周
function isSameWeek(weeklytime, time) {
	var day = new Date(time * 1000).getDay();
	//星期几
	var mintime = time - day * 3600 * 24;
	//一周开始时间
	var maxtime = time + (7 - day) * 3600 * 24;
	//一周结束时间
	if (weeklytime >= mintime && weeklytime <= maxtime) {
		return true;
	} else {
		return false;
	}
}

//判断是否在同一个月
function isSameMonth(nomal_time, now_time) {
	var nomal_month = new Date(nomal_time * 1000).getMonth() + 1;
	var now_month = new Date(now_time * 1000).getMonth() + 1;
	var nomal_year = new Date(nomal_time * 1000).getFullYear();
	var now_year = new Date(now_time * 1000).getFullYear();
	if (nomal_year == now_year) {
		if (nomal_month == now_month) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}

function CommentisNull(str) {
	if (str == null || str.length == 0) {
		return null;
	} else {
		return Base64.decode(str);
	}
}

function judgeiosTypeChange() {
	if (api.systemType == "ios") {
		$('#all_div').addClass('iosNomal');
	} else {
		$('#all_div').removeClass('iosNomal');
	}
}

//判断题设置选项
function panxuanzeReturnStr(i) {
	var num = (i + 1) % 2;
	switch(num) {
		case 0:
			return '错误'
			break;
		case 1:
			return '正确'
			break;
		default:
			return '暂无'
			break;
	}
}

//判断字符是否为空的方法
function isEmpty(obj) {
	if ( typeof obj == "undefined" || obj == null || obj == "" || obj == "null" || obj == "undefined" || obj == undefined) {
		return true;
	} else {
		return false;
	}

}

//判断对象是否为空
function isObjectEmpty(object) {
	if ( typeof object === 'object') {
		if (Object.keys(object).length === 0) {
			return true // 如果为空,返回false
		} else {
			return false
		}
	} else {//不是对象
		return true
	}
}

//判断数组是否为空
function isArrayEmpty(arr) {
	if (JSON.stringify(arr) === '[]' || arr.length === 0) {
		return true // 如果为空,返回false
	} else {
		return false
	}
}

//判断是否是整数
function isDecimal(number) {
	//	var str = number + "";

	if (String(number).indexOf(".") > -1) {
		return true;
	} else {
		return false;
	}

}

//是否是数字
function isNumber(val) {
	var regPos = /^\d+(\.\d+)?$/;
	//非负浮点数
	var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;
	//负浮点数
	if (regPos.test(val) || regNeg.test(val)) {
		return true;
	} else {
		return false;
	}
}

//是否是数组，是的话，返回true
function isArrayFn(arg) {
	if ( typeof arg === 'object') {
		return Object.prototype.toString.call(arg) === '[object Array]';
	}
	return false;
}

//获取到当前时间(学生端课堂签到功能使用)
function getCurrentTime() {
	var myDate = new Date();
	var hour = myDate.getHours();
	var minutes = myDate.getMinutes();
	if (parseInt(minutes) < 10) {
		minutes = '0' + minutes;
	}
	return hour + " : " + minutes;
}

//日期转换成周几
function dayTransformWeek(timeStamp) {
	var str = "周";
	var timeStampInt = parseInt(timeStamp13WithString(timeStamp.toString()));
	var timeDate = new Date(timeStampInt);
	var week = timeDate.getDay();
	//	alert(timeStampInt);
	switch (week) {
		case 0 :
			str += "日";
			break;
		case 1 :
			str += "一";
			break;
		case 2 :
			str += "二";
			break;
		case 3 :
			str += "三";
			break;
		case 4 :
			str += "四";
			break;
		case 5 :
			str += "五";
			break;
		case 6 :
			str += "六";
			break;
	}
	return str;
}

//获取当天的时间
function toadyTransformWeek() {

	var timeDate = new Date();
	var str = timeStringWithTimeStamp(timeDate) + '' + '周';
	var week = timeDate.getDay();
	//	alert(timeStampInt);
	switch (week) {
		case 0 :
			str += "日";
			break;
		case 1 :
			str += "一";
			break;
		case 2 :
			str += "二";
			break;
		case 3 :
			str += "三";
			break;
		case 4 :
			str += "四";
			break;
		case 5 :
			str += "五";
			break;
		case 6 :
			str += "六";
			break;
	}
	return str;

}

//数字不为负数,为负数置0s
function MorethanZero(str) {
	if (!isEmpty(str)) {
		if (parseInt(str) > 0) {
			return str;
		} else {
			return 0;
		}
	} else {
		return 0;
	}
}

//删除数组的空元素
function removeEmptyArrayEle(arr) {
	for (var i = 0; i < arr.length; i++) {
		if (isEmpty(arr[i])) {
			arr.splice(i, 1);
			i = i - 1;
			// i - 1 ,因为空元素在数组下标 2 位置，删除空之后，后面的元素要向前补位，
			// 这样才能真正去掉空元素,觉得这句可以删掉的连续为空试试，然后思考其中逻辑
		}
	}
	return arr;
};
//HTML转义
function HTMLEncode(html) {
	var temp = document.createElement("div");
	(temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
	var output = temp.innerHTML;
	temp = null;
	return output;
}

//HTML反转义
function HTMLDecode(text) {
	if (!isEmpty(text)) {
		var temp = document.createElement("div");
		temp.innerHTML = text;
		var output = temp.innerText || temp.textContent;
		temp = null;
		return output;
	} else {
		return ""
	}
}
//正则反转义html字符
function htmlDecodeByRegExp(str) {
	var s = "";
	if (str.length == 0)
		return "";
	s = str.replace(/&amp;/g, "&");
	s = s.replace(/&lt;/g, "<");
	s = s.replace(/&gt;/g, ">");
	s = s.replace(/&nbsp;/g, " ");
	s = s.replace(/&#39;/g, "\'");
	s = s.replace(/&quot;/g, "\"");
	return s;
}

